package com.shy.userservice.utils;

/**
 * Created with Intellij IDEA.
 *
 * @Author: RinMi
 * @Date: 2022/08/18/21:33
 * @Description:
 */
public class CodeGenerator {

    public int codeBit;

    public CodeGenerator(int codeBit){
        this.codeBit = codeBit;
    }

    public String generate(){

        StringBuilder code = new StringBuilder();
        //默认为4位
        if(codeBit != 4 && codeBit != 6){
            codeBit = 4;
        }

        for(int i = 0; i < codeBit; i++){
            code.append((int) (Math.random() * 10));
        }

        return code.toString();
    }

}
